<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:jeblog="http://rmannibucau.github.com/jeblog"
      xmlns:ui="http://java.sun.com/jsf/facelets">

<f:metadata>
  <f:viewParam name="tag" value="#{index.tag}" />
  <f:event type="preRenderView" listener="#{index.init}" />
</f:metadata>

<ui:composition template="/WEB-INF/template/layout.xhtml">
  <ui:define name="content">
    <div>
      <h1>Foo stuff!</h1>
      <p class="lead">Welcome message.</p>
    </div>
    <hr />

    <div id="posts">
      <ui:repeat value="#{index.posts}" var="it">
        <jeblog:post post="#{it}" />
      </ui:repeat>

      <h:form id="post-navigation" styleClass="pagination pagination-centered pagination-mini">
        <ul>
          <li>
            <h:commandLink actionListener="#{index.beginning}" update="posts">
              <h:outputText value="&#171;" />
            </h:commandLink>
          </li>
          <li>
            <h:commandLink  actionListener="#{index.previousPage}" rendered="#{index.hasPrevious}" update="posts">
              <h:outputText value="&#8249;" />
            </h:commandLink>
          </li>
          <li class="active">
            <a href="#"><h:outputText value="#{index.current}" /></a>
          </li>
          <li>
            <h:commandLink actionListener="#{index.nextPage}" rendered="#{index.hasNext}" update="posts">
              <h:outputText value="&#8250;" />
            </h:commandLink>
          </li>
          <li>
            <h:commandLink actionListener="#{index.end}" update="posts">
              <h:outputText value="&#187;" />
            </h:commandLink>
          </li>
        </ul>
      </h:form>
    </div>
  </ui:define>
</ui:composition>
</html>
